#!/usr/bin/env python3
#-*- coding: utf-8 -*-

import os
import sys

a = sys.argv
l = len(sys.argv)

# cpp compile options
cco = '-g -Wall -DLOCAL'

def ccpp(file):# file without filename extension
    if os.system('g++ ./%s.cpp -o %s %s 2> compile_log' %(file, file, cco)):
        print('Compile Error\n')
        print('/////////////////////////////\n')
        os.system('cat ./compile_log')
        os.system('rm ./compile_log')
        print('\n/////////////////////////////')
        quit()
    else: os.system('rm ./compile_log')

def run(file):
    print('name: %s' %file)
    os.system('./%s' %file)

if l == 1:
    print('please input the operations!!!')
    print('-ccpp [filename]  # cpp compile')
    print('-r [file]         # run the program')
else:
    op = a[1]
    file = a[2]
    if op == '-ccpp':
        print('compile options are: \'%s\'' %cco)
        ccpp(file)
    elif op == '-r':
         = file[len(file) - 3]
        run(file)

# TODO LIS
#*1. c++ complie         -ccpp [file]
#*2. c++ or python run   -r [file]
# 3. c++ judge
# 4. c++ debug